//
//  CartTableViewCell.m
//  FreshBee
//
//  Created by 马太行 on 2016/10/16.
//  Copyright © 2016年 iOS013. All rights reserved.
//

#import "CartTableViewCell.h"
@interface CartTableViewCell ()



@end

@implementation CartTableViewCell


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (instancetype) initWithCart:(NSIndexPath *)indexPath
{
    self =  [super init];
    
    
    switch (indexPath.section) {
        case 0:
        {
            //收货人Lable
            UILabel *CartName = [[UILabel alloc]init];
            [self.contentView addSubview:CartName];
            CartName.font = [UIFont systemFontOfSize:13];
            [CartName mas_makeConstraints:^(MASConstraintMaker *make) {
                make.size.mas_equalTo(CGSizeMake(240, 15));
                make.top.equalTo(self.contentView.mas_top).offset(11);
                make.left.equalTo(self.contentView.mas_left).offset(15);
            }];
            CartName.text = @"收 货 人     维尼的小熊先生";
            
            //收货电话
            UILabel *CartPhoneNumber = [[UILabel alloc]init];
             [self.contentView addSubview:CartPhoneNumber];
            CartPhoneNumber.font = [UIFont systemFontOfSize:13];
            [CartPhoneNumber mas_makeConstraints:^(MASConstraintMaker *make) {
                make.size.mas_equalTo(CGSizeMake(240, 15));
                make.top.equalTo(CartName.mas_bottom).offset(6);
                make.left.equalTo(self.contentView).offset(15);
            }];
            CartPhoneNumber.text = @"电      话     18833331111";
           
            
            //收货地址
            UILabel *CartAddress = [[UILabel alloc]init];
            [self.contentView addSubview:CartAddress];
            CartAddress.font = [UIFont systemFontOfSize:13];
            [CartAddress mas_makeConstraints:^(MASConstraintMaker *make) {
                make.size.mas_equalTo(CGSizeMake(240, 15));
                make.top.equalTo(CartPhoneNumber.mas_bottom).offset(6);
                make.left.equalTo(self.contentView).offset(15);
            }];
            CartAddress.text = @"收货地址     人民大会堂 9527办公室";
            
            //修改BTN
            UIButton *CartAlter = [[UIButton alloc]init];
            [self.contentView addSubview:CartAlter];
            
            [CartAlter mas_makeConstraints:^(MASConstraintMaker *make) {
                make.size.mas_equalTo(CGSizeMake(50,50));
               
                make.top.equalTo(self.contentView.mas_top).offset(15);
                make.right.equalTo(self.contentView.mas_right).offset(-25);
                make.size.mas_equalTo(CGSizeMake(50,50));
            }];
            [CartAlter setTitle:@"修改" forState:UIControlStateNormal];
            [CartAlter setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
            [CartAlter setTitleColor:[UIColor yellowColor] forState:UIControlStateHighlighted];
        
       
            //设置背景图片
            UIImageView *upImage = [[UIImageView alloc]init];
            [self.contentView addSubview:upImage];
            upImage.image = [UIImage imageNamed:@"v2_shoprail"];
            [upImage mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.top.equalTo(self.contentView.mas_top).offset(0);
                make.width.equalTo(self.contentView);
                make.height.mas_equalTo(2);
            }];
            
            UIImageView *downImage = [[UIImageView alloc]init];
            [self.contentView addSubview:downImage];
            downImage.image = [UIImage imageNamed:@"v2_shoprail"];
            [downImage mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.bottom.equalTo(self.contentView.mas_bottom).offset(0);
                make.width.equalTo(self.contentView);
                make.height.mas_equalTo(2);
            }];
            
            //右方箭头
            UIImageView *rihgtArrow = [[UIImageView alloc]init];
            [self.contentView addSubview:rihgtArrow];
            rihgtArrow.image = [UIImage imageNamed:@"icon_go"];
            [rihgtArrow mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.top.equalTo(self.contentView.mas_top).offset(35);
                make.right.equalTo(self.contentView.mas_right).offset(-15);
                make.size.mas_equalTo(CGSizeMake(5,10));
          
            }];
            
        }
            break;
        case 1:
        {
            switch (indexPath.row) {
                case 0:
                {
                    
                    //🚀图片
                    UIImageView *CartImage = [[UIImageView alloc]init];
                    [self.contentView addSubview:CartImage];

                    [CartImage mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.size.mas_equalTo(CGSizeMake(20, 20));
                        make.left.equalTo(self.contentView.mas_left).offset(15);
                        make.top.equalTo(self.contentView.mas_top).offset(15);
                    }];
                    CartImage.image = [UIImage imageNamed:@"icon_lighting"];
                    
                    // title
                    UILabel *CartTitle= [[UILabel alloc]init];
                      CartTitle.font = [UIFont systemFontOfSize:13];
                     [self.contentView addSubview:CartTitle];
                    CartTitle.textColor = [UIColor grayColor];

                    [CartTitle mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.size.mas_equalTo(CGSizeMake(150, 20));
                        make.left.equalTo(CartImage.mas_right).offset(15);
                        make.centerY.equalTo(CartImage.mas_centerY);
                    }];
                    CartTitle.text = @"闪电超市";
                   
                    
                    //红点
                    UIImageView *CartPoint = [[UIImageView alloc]init];
                    [self.contentView addSubview:CartPoint];

                    [CartPoint mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.size.mas_equalTo(CGSizeMake(5, 5));
                        make.centerX.equalTo(CartImage.mas_centerX);
                        make.top.equalTo(CartImage.mas_bottom).offset(15);
                        
                    }];
                    CartPoint.image = [UIImage imageNamed:@"v2_notice_dot"];
                    
                    //文本信息
                    UILabel *CartText= [[UILabel alloc]init];
                      CartText.font = [UIFont systemFontOfSize:13];
                    [self.contentView addSubview:CartText];

                    [CartText mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.size.mas_equalTo(CGSizeMake(300, 20));
                        make.left.equalTo(CartPoint.mas_right).offset(15);
                        make.centerY.equalTo(CartPoint.mas_centerY);

                        
                    }];
                    CartText.text = @"22:00前满$30免运费,22:00后满$50免运费";
                    CartText.textColor = [UIColor grayColor];
                    
                }
                    break;
                case 1:
                {
                    
                    // 收货时间
                    UILabel *CartTime= [[UILabel alloc]init];
                    [self.contentView addSubview:CartTime];
                    
                    [CartTime mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.size.mas_equalTo(CGSizeMake(100, 20));
                        make.left.equalTo(self.contentView.mas_left).offset(15);
                        make.centerY.equalTo(self.contentView.mas_centerY);
                    }];
                    CartTime.text = @"收货时间";
                    
                    
                    //  title
                    UILabel *CartTitle = [[UILabel alloc]init];
                    [self.contentView addSubview:CartTitle];
                    
                    [CartTitle mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.size.mas_equalTo(CGSizeMake(200, 20));
                        make.left.equalTo(CartTime.mas_right).offset(10);
                        make.centerY.equalTo(CartTime.mas_centerY);
                    }];
                    CartTitle.text = @"闪电送,及时达";
                    CartTitle.textColor = [UIColor redColor];
                    
                    //文本信息
                    UILabel *CartText= [[UILabel alloc]init];
                    [self.contentView addSubview:CartText];
                    
                    [CartText mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.size.mas_equalTo(CGSizeMake(70, 20));
                        make.right.equalTo(self.contentView.mas_right).offset(-20);
                        make.centerY.equalTo(CartTime.mas_centerY);
                        
                        
                    }];
                    CartText.text = @"可预订";
                    CartText.textColor = [UIColor redColor];
                    
                    
                    //箭头
                    self.accessoryType = UITableViewCellStyleValue1;
                    
                }
                    break;
                case 2:
                {
                    
                    // 收货时间
                    UILabel *CartRemark = [[UILabel alloc]init];
                    [self.contentView addSubview:CartRemark];
                    
                    [CartRemark mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.size.mas_equalTo(CGSizeMake(80, 20));
                        make.left.equalTo(self.contentView.mas_left).offset(15);
                        make.centerY.equalTo(self.contentView.mas_centerY);
                    }];
                    CartRemark.text = @"收货备注";
                    
                 //textfiled
                    UITextField *textField = [[UITextField alloc]init];
                    textField.borderStyle = UITextBorderStyleRoundedRect;
                    textField.font = [UIFont systemFontOfSize:14];
              
                    [self.contentView addSubview:textField];
                    [textField mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.height.mas_equalTo(40);
                        make.left.equalTo(CartRemark.mas_right).offset(15);
                        make.right.equalTo(self.contentView.mas_right).offset(-20);
                        make.centerY.equalTo(self.contentView.mas_centerY);
                    }];
                    textField.placeholder = @"可输入100字以内特殊要求内容";
                    //自动联想关闭
                    [textField setAutocorrectionType:UITextAutocorrectionTypeNo];
                    //关闭首字母大写
                    [textField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
                }
                    break;
   
                    
                    
                default:
                    break;
            }
        
        
        
        }
            break;
            
               default:
            break;
    }
    
    
    
    
    return self;
}





@end
